<?php
namespace app\components;

use yii;
use app\modules\Manage\models\User;

class Role  extends \yii\base\Widget
{

	//获取所有人员
	public function getAll(){

		$model = User::find()->all();

		return $model;

	}

	//获取所有操作
	public function getAllOper(){
		$model = $this->getAll();
		$res = [];
		if($model){
			foreach($model as $m){
				$roles = [];
				$roles = Yii::$app->authManager->getRolesByUser($m->id);
				$role_arr = [];   
		        if($roles){
		            foreach($roles as $role){
		                $role_arr[] = $role->name;
		            }
		        }
		        if(in_array("操作", $role_arr)){
		            $res[$m->id] = $m->name;
		        }
			}
		}
		return $res;
	}


}